package population.phaseExecutors;

import java.util.ArrayList;

import population.Population;

/**
 * Composite phase.
 * @author pcdejager
 */
public class CompositePhase implements PhaseExecutor {
    /**
     * Constructor.
     */
    public CompositePhase() {
        phases = new ArrayList<PhaseExecutor>();
    }
    /**
     * Add a phase to be executed.
     * @param phase Phase to add
     */
    public final void addPhase(final PhaseExecutor phase) {
        phases.add(phase);
    }
    /**
     * Get the size of phases in this composite phase.
     * @return The size
     */
    public final int size() {
        return phases.size();
    }
    /**
     * Execute the phases.
     * @param p The population to execute on
     */
    public final void execute(final Population p) {
        for (PhaseExecutor phase : phases) {
            phase.execute(p);
        }
    }
    /**
     * Phases to execute.
     */
    private ArrayList<PhaseExecutor> phases = null;
}
